﻿var ServerSideMessage = window.ssm = {
    message: null,                  // message
    title: null,                    // title
    isActive: false,                // "True" if error occured
    NotifyType: -1,                 // type
    showServerSideMessage: showServerSideMessage
};

var NotifyType = {
    INFORMATION: 0,
    WARNING: 1,
    ERROR: 2,
    SUCCESS: 3
};

//shows server-side message if it exists
function showServerSideMessage() {
    var message = ssm.message;
    var type = ssm.type;
    var title = ssm.title;
    var isActive = ssm.isActive;
    if (isActive == 'True') { //needs to show server-side message
        if (type == NotifyType.SUCCESS) {
            Notifier.success(message, title);
        }
        if (type == NotifyType.WARNING) {
            Notifier.warning(message, title);
        }
        if (type == NotifyType.INFORMATION) {
            Notifier.info(message, title);
        }
        if (type == NotifyType.ERROR) {
            Notifier.customError(message, title, null, false);
        }
    }
}


//main method on master page load
function OnLoad() {
    try {
        //shows server side error if error exists
        if (showServerSideMessage) showServerSideMessage();

        //calls content page onPageLoad() function if it exists
        if (window.onPageLoad) {
            Notifier.debug('contentOnLoad is exists', 'contentOnLoad',null,3000);
            window.onPageLoad();
        }
    }
    catch (e) {
        Notifier.error(e);
    }
}